
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>面向对象 · Dart编程指南</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="arcticfox">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="泛型.html" />
    
    
    <link rel="prev" href="进阶篇.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.bczl.xyz/" target="_blank" class="custom-link">主页</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="基础篇.html">
            
                <a href="基础篇.html">
            
                    
                    基础篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="环境搭建.html">
            
                <a href="环境搭建.html">
            
                    
                    环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="简单语法.html">
            
                <a href="简单语法.html">
            
                    
                    简单语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="进阶篇.html">
            
                <a href="进阶篇.html">
            
                    
                    进阶篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="面向对象.html">
            
                <a href="面向对象.html">
            
                    
                    面向对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="泛型.html">
            
                <a href="泛型.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="枚举.html">
            
                <a href="枚举.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="库与导入.html">
            
                <a href="库与导入.html">
            
                    
                    库与导入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="异步编程.html">
            
                <a href="异步编程.html">
            
                    
                    异步编程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.5.1" data-path="异步编程之Future.html">
            
                <a href="异步编程之Future.html">
            
                    
                    Future
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.2" data-path="异步编程之Stream.html">
            
                <a href="异步编程之Stream.html">
            
                    
                    Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5.3" data-path="异步编程之Isolate.html">
            
                <a href="异步编程之Isolate.html">
            
                    
                    Isolate
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="异常处理.html">
            
                <a href="异常处理.html">
            
                    
                    异常处理与 Zone
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="生成器.html">
            
                <a href="生成器.html">
            
                    
                    生成器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="标准流与文件.html">
            
                <a href="标准流与文件.html">
            
                    
                    标准流与文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="运算符.html">
            
                <a href="运算符.html">
            
                    
                    附：运算符
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="常用标准库.html">
            
                <a href="常用标准库.html">
            
                    
                    常用标准库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="字符串.html">
            
                <a href="字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="集合.html">
            
                <a href="集合.html">
            
                    
                    集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="URI处理.html">
            
                <a href="URI处理.html">
            
                    
                    URI处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="日期和时间.html">
            
                <a href="日期和时间.html">
            
                    
                    日期和时间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="环境及外部调用.html">
            
                <a href="环境及外部调用.html">
            
                    
                    环境及外部调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="其他.html">
            
                <a href="其他.html">
            
                    
                    其他
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="实战篇.html">
            
                <a href="实战篇.html">
            
                    
                    实战篇
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="网络编程.html">
            
                <a href="网络编程.html">
            
                    
                    网络编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="爬虫实战.html">
            
                <a href="爬虫实战.html">
            
                    
                    爬虫实战
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="HTTP服务器.html">
            
                <a href="HTTP服务器.html">
            
                    
                    HTTP服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="WebSocket服务器.html">
            
                <a href="WebSocket服务器.html">
            
                    
                    WebSocket服务器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    附录
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="dart2.14.html">
            
                <a href="dart2.14.html">
            
                    
                    升级到Dart 2.14
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="http://www.bczl.xyz/" target="blank" class="gitbook-link">
            编程之路
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >面向对象</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#&#x9762;&#x5411;&#x5BF9;&#x8C61;"><b></b>&#x9762;&#x5411;&#x5BF9;&#x8C61;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6982;&#x8FF0;"><b></b>&#x6982;&#x8FF0;</a></li><li><span class="title-icon "></span><a href="#&#x7C7B;&#x7684;&#x5B9A;&#x4E49;"><b></b>&#x7C7B;&#x7684;&#x5B9A;&#x4E49;</a></li><li><span class="title-icon "></span><a href="#getters-&#x548C;-setters&#x65B9;&#x6CD5;"><b></b>Getters &#x548C; Setters&#x65B9;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#&#x6784;&#x9020;&#x65B9;&#x6CD5;"><b></b>&#x6784;&#x9020;&#x65B9;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#&#x7C7B;&#x7684;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;"><b></b>&#x7C7B;&#x7684;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;</a></li><li><span class="title-icon "></span><a href="#&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;"><b></b>&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;</a></li><li><span class="title-icon "></span><a href="#&#x7C7B;&#x7684;&#x7EE7;&#x627F;&#x4E0E;&#x6DF7;&#x5165;"><b></b>&#x7C7B;&#x7684;&#x7EE7;&#x627F;&#x4E0E;&#x6DF7;&#x5165;</a></li><li><span class="title-icon "></span><a href="#&#x63A5;&#x53E3;&#x62BD;&#x8C61;"><b></b>&#x63A5;&#x53E3;&#x62BD;&#x8C61;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><!-- ex_nolevel -->
<h2 id="&#x9762;&#x5411;&#x5BF9;&#x8C61;"><a name="&#x9762;&#x5411;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x9762;&#x5411;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9762;&#x5411;&#x5BF9;&#x8C61;</h2>
<h3 id="&#x6982;&#x8FF0;"><a name="&#x6982;&#x8FF0;" class="anchor-navigation-ex-anchor" href="#&#x6982;&#x8FF0;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6982;&#x8FF0;</h3>
<p>&#x6240;&#x8C13;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#xFF0C;&#x662F;&#x76F8;&#x5BF9;&#x4E8E;&#x9762;&#x5411;&#x8FC7;&#x7A0B;&#x800C;&#x8A00;&#x7684;&#x3002;&#x90A3;&#x4EC0;&#x4E48;&#x662F;&#x9762;&#x5411;&#x8FC7;&#x7A0B;&#x5462;&#xFF1F;C&#x8BED;&#x8A00;&#x5C31;&#x662F;&#x4E00;&#x79CD;&#x5178;&#x578B;&#x7684;&#x9762;&#x5411;&#x8FC7;&#x7A0B;&#x7684;&#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#x3002;&#x5176;&#x5B9E;&#x8FC7;&#x7A0B;&#x4E5F;&#x5C31;&#x662F;&#x6240;&#x8C13;&#x7684;&#x6B65;&#x9AA4;&#x3002;&#x6709;&#x4E00;&#x4E2A;&#x7ECF;&#x5178;&#x4F8B;&#x5B50;&#x662F;&#x8FD9;&#x6837;&#x7684;&#xFF0C;&#x5982;&#x4F55;&#x628A;&#x5927;&#x8C61;&#x653E;&#x8FDB;&#x51B0;&#x7BB1;&#xFF1F;</p>
<ol>
<li>&#x628A;&#x51B0;&#x7BB1;&#x95E8;&#x6253;&#x5F00;</li>
<li>&#x628A;&#x5927;&#x8C61;&#x653E;&#x8FDB;&#x53BB;</li>
<li>&#x628A;&#x51B0;&#x7BB1;&#x95E8;&#x5173;&#x4E0A;</li>
</ol>
<p>&#x6709;&#x4E9B;&#x4EBA;&#x53EF;&#x80FD;&#x4F1A;&#x89C9;&#x5F97;&#x8352;&#x8BDE;&#xFF0C;&#x5927;&#x8C61;&#x600E;&#x4E48;&#x80FD;&#x653E;&#x5F97;&#x8FDB;&#x51B0;&#x7BB1;&#x5462;&#xFF1F;&#x7136;&#x800C;&#x8FD9;&#x5C31;&#x662F;&#x9762;&#x5411;&#x8FC7;&#x7A0B;&#x7684;&#x601D;&#x7EF4;&#x65B9;&#x5F0F;&#xFF0C;C&#x8BED;&#x8A00;&#x4EE3;&#x7801;&#x5982;&#x4E0B;</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">openDoor</span><span class="hljs-params">()</span></span>{}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">put</span><span class="hljs-params">(<span class="hljs-keyword">void</span> *)</span></span>{}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">closeDoor</span><span class="hljs-params">()</span></span>{}

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span></span>{
    <span class="hljs-comment">// &#x6253;&#x5F00;&#x95E8;</span>
    openDoor();
    <span class="hljs-comment">// &#x653E;&#x8FDB;&#x53BB;</span>
    put(obj);
    <span class="hljs-comment">// &#x5173;&#x4E0A;&#x95E8;</span>
    closeDoor();
}
</code></pre>
<p>&#x6BCF;&#x4E00;&#x4E2A;&#x6B65;&#x9AA4;&#x5BF9;&#x5E94;&#x5230;&#x4EE3;&#x7801;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x6BCF;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x5B9E;&#x73B0;&#x4E00;&#x4E2A;&#x529F;&#x80FD;&#xFF0C;&#x7136;&#x540E;&#x5206;&#x6B65;&#x8C03;&#x7528;&#x8FD9;&#x4E9B;&#x51FD;&#x6570;&#x3002;&#x8FD9;&#x4E9B;&#x51FD;&#x6570;&#x53EF;&#x80FD;&#x662F;&#x6211;&#x4EEC;&#x81EA;&#x5DF1;&#x5199;&#x7684;&#xFF0C;&#x4E5F;&#x53EF;&#x80FD;&#x662F;&#x522B;&#x4EBA;&#x5199;&#x7684;&#xFF0C;&#x51FD;&#x6570;&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x4E00;&#x4E2A;&#x9ED1;&#x76D2;&#x6A21;&#x578B;&#xFF0C;&#x8FD9;&#x4E2A;&#x76D2;&#x5B50;&#x662F;&#x5C01;&#x95ED;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x77E5;&#x9053;&#x91CC;&#x9762;&#x6709;&#x4EC0;&#x4E48;&#xFF0C;&#x53EA;&#x77E5;&#x9053;&#x8FD9;&#x4E2A;&#x76D2;&#x5B50;&#x6709;&#x4E00;&#x4E2A;&#x5165;&#x53E3;&#x548C;&#x4E00;&#x4E2A;&#x51FA;&#x53E3;&#xFF0C;&#x5C31;&#x5982;&#x540C;ATM&#x673A;&#xFF0C;&#x6211;&#x4EEC;&#x628A;&#x5361;&#x63D2;&#x5230;&#x5165;&#x53E3;&#xFF0C;&#x53E6;&#x4E00;&#x8FB9;&#x51FA;&#x53E3;&#x5C31;&#x5192;&#x94B1;&#x51FA;&#x6765;&#x4E86;&#xFF0C;&#x81F3;&#x4E8E;&#x5177;&#x4F53;&#x7684;&#xFF0C;&#x94B1;&#x662F;&#x600E;&#x4E48;&#x5192;&#x51FA;&#x6765;&#x7684;&#xFF0C;&#x8FD9;&#x4E0D;&#x662F;&#x6211;&#x4EEC;&#x5173;&#x5FC3;&#x7684;&#x3002;&#x56DE;&#x5230;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x5927;&#x8C61;&#x80FD;&#x4E0D;&#x80FD;&#x653E;&#x8FDB;&#x51B0;&#x7BB1;&#xFF0C;&#x8FD9;&#x4E5F;&#x4E0D;&#x662F;&#x6211;&#x4EEC;&#x5173;&#x5FC3;&#x7684;&#xFF0C;&#x603B;&#x4E4B;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x5C31;&#x662F;&#x628A;&#x5927;&#x8C61;&#x653E;&#x8FDB;&#x51B0;&#x7BB1;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x53EA;&#x7BA1;&#x8C03;&#x7528;&#x5B83;&#x5C31;&#x597D;&#x4E86;&#x3002;</p>
<p>&#x6709;&#x4E86;&#x8FD9;&#x79CD;&#x9762;&#x5411;&#x8FC7;&#x7A0B;&#x7684;&#x601D;&#x7EF4;&#x65B9;&#x5F0F;&#xFF0C;&#x7F16;&#x7A0B;&#x5C31;&#x53D8;&#x5F97;&#x7B80;&#x5355;&#x6E05;&#x6670;&#x6709;&#x6761;&#x7406;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5148;&#x628A;&#x6574;&#x4E2A;&#x67B6;&#x5B50;&#x5148;&#x642D;&#x8D77;&#x6765;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x51FD;&#x6570;&#x5148;&#x7A7A;&#x5B9E;&#x73B0;&#xFF0C;&#x6574;&#x4E2A;&#x67B6;&#x5B50;&#x5EFA;&#x597D;&#x4E86;&#xFF0C;&#x518D;&#x6162;&#x6162;&#x53BB;&#x5B9E;&#x73B0;&#x8FD9;&#x4E00;&#x4E2A;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x5177;&#x4F53;&#x7EC6;&#x8282;&#x3002;&#x8FD9;&#x8DDF;&#x5EFA;&#x623F;&#x5B50;&#x4E00;&#x6837;&#xFF0C;&#x5148;&#x628A;&#x94A2;&#x7ED3;&#x6784;&#x67B6;&#x5B50;&#x642D;&#x8D77;&#x6765;&#xFF0C;&#x7136;&#x540E;&#x518D;&#x6162;&#x6162;&#x7801;&#x7816;&#x780C;&#x5899;&#xFF0C;&#x6700;&#x540E;&#x624D;&#x662F;&#x5BA4;&#x5185;&#x88C5;&#x4FEE;&#x3002;</p>
<p>&#x968F;&#x7740;&#x8F6F;&#x4EF6;&#x4E1A;&#x7684;&#x53D1;&#x5C55;&#xFF0C;&#x9700;&#x6C42;&#x8D8A;&#x6765;&#x8D8A;&#x590D;&#x6742;&#xFF0C;&#x4EBA;&#x4EEC;&#x53D1;&#x73B0;&#x9762;&#x5411;&#x8FC7;&#x7A0B;&#x7684;&#x601D;&#x7EF4;&#x6A21;&#x578B;&#x592A;&#x7B80;&#x5355;&#x4E86;&#xFF0C;&#x5DF2;&#x7ECF;&#x65E0;&#x6CD5;&#x80DC;&#x4EFB;&#x65E5;&#x76CA;&#x590D;&#x6742;&#x7684;&#x8F6F;&#x4EF6;&#x9700;&#x6C42;&#x4E86;&#xFF0C;&#x4E8E;&#x662F;&#x5C31;&#x51FA;&#x73B0;&#x4E86;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7684;&#x601D;&#x7EF4;&#x65B9;&#x5F0F;&#x3002;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x65E2;&#x662F;&#x4E00;&#x79CD;&#x601D;&#x7EF4;&#x6A21;&#x578B;&#xFF0C;&#x4E5F;&#x662F;&#x4E00;&#x79CD;&#x4EE3;&#x7801;&#x7684;&#x7EC4;&#x7EC7;&#x5F62;&#x5F0F;&#x3002;</p>
<p>&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x6838;&#x5FC3;&#x7684;&#x8F7D;&#x4F53;&#x662F;&#x7C7B;&#x548C;&#x5BF9;&#x8C61;&#x3002;&#x90A3;&#x4EC0;&#x4E48;&#x662F;&#x7C7B;&#xFF1F;&#x4EC0;&#x4E48;&#x662F;&#x5BF9;&#x8C61;&#x5462;&#xFF1F;</p>
<h4 id="&#x4EC0;&#x4E48;&#x662F;&#x5BF9;&#x8C61;"><a name="&#x4EC0;&#x4E48;&#x662F;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x4EC0;&#x4E48;&#x662F;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EC0;&#x4E48;&#x662F;&#x5BF9;&#x8C61;</h4>
<p>&#x8981;&#x8BF4;&#x6E05;&#x695A;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#xFF0C;&#x5F97;&#x5148;&#x89E3;&#x91CA;&#x4EC0;&#x4E48;&#x662F;&#x5BF9;&#x8C61;&#xFF0C;&#x4E0D;&#x7136;&#x8FD8;&#x600E;&#x4E48;&#x53BB;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x5462;&#x3002;&#x5728;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7684;&#x54F2;&#x5B66;&#x91CC;&#xFF0C;&#x6709;&#x4E00;&#x53E5;&#x8BDD;&#x662F;&#x201C;&#x4E00;&#x5207;&#x7686;&#x5BF9;&#x8C61;&#xFF01;&#x201D;&#x5BF9;&#x8C61;&#x4E00;&#x8BCD;&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x4ECE;&#x82F1;&#x8BED;&#x7FFB;&#x8BD1;&#x8FC7;&#x6765;&#x7684;&#xFF0C;&#x8FD9;&#x4E2A;&#x7FFB;&#x8BD1;&#x5176;&#x5B9E;&#x662F;&#x4E0D;&#x51C6;&#x786E;&#x7684;&#xFF0C;&#x6700;&#x91CD;&#x8981;&#x7684;&#x5C31;&#x662F;&#x6CA1;&#x6709;&#x6307;&#x660E;&#x8FD9;&#x4E2A;&#x6982;&#x5FF5;&#x7684;&#x5185;&#x6DB5;&#x3002;&#x5B83;&#x7684;&#x82F1;&#x6587;<code>object</code>&#x5B9E;&#x9645;&#x4E0A;&#x8868;&#x8FBE;&#x7684;&#x662F;&#x5177;&#x4F53;&#x4E8B;&#x7269;&#xFF0C;&#x5BA2;&#x89C2;&#x4E8B;&#x7269;&#xFF0C;&#x5BA2;&#x4F53;&#x7684;&#x610F;&#x601D;&#x3002;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x5C06;&#x5177;&#x4F53;&#x4E8B;&#x7269;&#x62BD;&#x8C61;&#x5316;&#xFF0C;&#x7528;&#x4E00;&#x53E5;&#x661F;&#x7237;&#x7535;&#x5F71;&#x300A;&#x529F;&#x592B;&#x300B;&#x4E2D;&#x7684;&#x53F0;&#x8BCD;&#x6765;&#x89E3;&#x91CA;&#x5C31;&#x662F;&#x201C;&#x90A3;&#x4E2A;&#x8C01;&#x201D;&#x7684;&#x610F;&#x601D;&#xFF0C;&#x5C31;&#x662F;&#x5C06;&#x4E00;&#x5207;&#x7684;&#x5177;&#x4F53;&#x4E8B;&#x7269;&#xFF0C;&#x62BD;&#x8C61;&#x51FA;&#x4E00;&#x4E2A;&#x5171;&#x540C;&#x7684;&#x6307;&#x4EE3;&#x6A21;&#x578B;&#xFF0C;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x8BF4;&#x201C;&#x90A3;&#x4E2A;&#x4E1C;&#x897F;&#x201D;&#x3001;&#x201C;&#x90A3;&#x4E2A;&#x4E8B;&#x7269;&#x201D;&#xFF0C;&#x4F60;&#x5728;&#x8BF4;&#x8FD9;&#x53E5;&#x8BDD;&#x65F6;&#xFF0C;&#x4E00;&#x5B9A;&#x662F;&#x6307;&#x7684;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x5B58;&#x5728;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x7A7A;&#x6CDB;&#x7684;&#x865A;&#x65E0;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x8FD9;&#x5C31;&#x662F;&#x5BF9;&#x8C61;&#x7684;&#x7279;&#x70B9;&#x3002;</p>
<h4 id="&#x4EC0;&#x4E48;&#x662F;&#x7C7B;"><a name="&#x4EC0;&#x4E48;&#x662F;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#&#x4EC0;&#x4E48;&#x662F;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4EC0;&#x4E48;&#x662F;&#x7C7B;</h4>
<p>&#x4E86;&#x89E3;&#x4E86;&#x5BF9;&#x8C61;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x7981;&#x8981;&#x95EE;&#xFF0C;&#x7F16;&#x7A0B;&#x4E2D;&#x600E;&#x4E48;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#xFF0C;&#x600E;&#x4E48;&#x8FD0;&#x7528;&#x5BF9;&#x8C61;&#x5462;&#xFF1F;&#x53EF;&#x4EE5;&#x8BD5;&#x60F3;&#x4E00;&#x4E0B;&#xFF0C;&#x5047;&#x8BBE;&#x6211;&#x4EEC;&#x73B0;&#x5728;&#x60F3;&#x8981;&#x63CF;&#x8FF0;&#x732B;&#x8FD9;&#x79CD;&#x52A8;&#x7269;&#xFF0C;&#x8BE5;&#x600E;&#x4E48;&#x505A;&#xFF1F;</p>
<p>&#x9996;&#x5148;&#x53EF;&#x4EE5;&#x89C2;&#x5BDF;&#x5177;&#x4F53;&#x7684;&#x732B;&#xFF0C;&#x7136;&#x540E;&#x5C06;&#x6240;&#x6709;&#x732B;&#x90FD;&#x5177;&#x5907;&#x7684;&#x7279;&#x5F81;&#x63D0;&#x53D6;&#x51FA;&#x6765;&#xFF0C;&#x62BD;&#x8C61;&#x51FA;&#x6765;&#xFF0C;&#x8FD9;&#x4E2A;&#x62BD;&#x8C61;&#x51FA;&#x6765;&#x7684;&#x6A21;&#x578B;&#x4E5F;&#x5C31;&#x662F;<strong>&#x7C7B;</strong>&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x732B;&#x90FD;&#x6709;&#x5C3E;&#x5DF4;&#xFF0C;&#x6709;&#x6BDB;&#xFF0C;&#x5706;&#x773C;&#x7AD6;&#x77B3;&#xFF0C;&#x559C;&#x6B22;&#x7761;&#x89C9;&#xFF0C;&#x663C;&#x4F0F;&#x591C;&#x51FA;&#xFF0C;&#x4F1A;&#x6293;&#x8001;&#x9F20;&#xFF0C;&#x4F1A;&#x55B5;&#x55B5;&#x53EB;&#xFF0C;&#x559C;&#x6B22;&#x5403;&#x9C7C;&#x7B49;&#x7B49;&#x3002;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x5C31;&#x63D0;&#x53D6;&#x51E0;&#x4E2A;&#x7279;&#x5F81;&#xFF0C;&#x5F62;&#x6210;&#x4E00;&#x4E2A;&#x732B;&#x7C7B;</p>
<ul>
<li>&#x5706;&#x773C;&#x7AD6;&#x77B3;</li>
<li>&#x6709;&#x76AE;&#x6BDB;</li>
<li>&#x5403;&#x9C7C;</li>
<li>&#x6293;&#x8001;&#x9F20;</li>
<li>&#x7761;&#x89C9;</li>
</ul>
<p>&#x6709;&#x4E86;&#x7C7B;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x5224;&#x65AD;&#x4E00;&#x53EA;&#x732B;&#x662F;&#x5426;&#x5C5E;&#x4E8E;&#x732B;&#x7C7B;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x8FD9;&#x4E2A;&#x7C7B;&#x6279;&#x91CF;&#x521B;&#x9020;&#x732B;&#x3002;&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#xFF0C;&#x7C7B;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x8BBE;&#x8BA1;&#x84DD;&#x56FE;&#xFF0C;&#x6216;&#x8005;&#x8BF4;&#x662F;&#x4E00;&#x4E2A;&#x6A21;&#x5177;&#xFF0C;&#x6240;&#x6709;&#x4F9D;&#x636E;&#x8FD9;&#x4E2A;&#x84DD;&#x56FE;&#x521B;&#x9020;&#x7684;&#x5177;&#x4F53;&#x7684;&#x732B;&#x90FD;&#x662F;&#x8FD9;&#x4E2A;&#x7C7B;&#x7684;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x3002;&#x7C7B;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x56FE;&#x7EB8;&#xFF0C;&#x5BF9;&#x8C61;&#x5C31;&#x662F;&#x8FD9;&#x4E2A;&#x56FE;&#x7EB8;&#x7684;&#x5177;&#x4F53;&#x4E8B;&#x7269;&#x3002;</p>
<p>&#x7C7B;&#x6240;&#x5305;&#x542B;&#x7684;&#x7279;&#x5F81;&#xFF0C;&#x6211;&#x4EEC;&#x901A;&#x5E38;&#x5206;&#x4E3A;&#x4E24;&#x79CD;&#x7C7B;&#x578B;&#xFF0C;&#x5C5E;&#x6027;&#x548C;&#x884C;&#x4E3A;&#x3002;&#x5C5E;&#x6027;&#x662F;&#x9759;&#x6001;&#x7684;&#x63CF;&#x8FF0;&#xFF0C;&#x884C;&#x4E3A;&#x662F;&#x52A8;&#x6001;&#x7684;&#x7279;&#x5F81;&#x3002;&#x4EE5;&#x4E0A;&#x9762;&#x7684;&#x732B;&#x7C7B;&#x4E3A;&#x4F8B;</p>
<table>
<thead>
<tr>
<th>&#x5C5E;&#x6027;</th>
<th>&#x884C;&#x4E3A;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x5706;&#x773C;&#x7AD6;&#x77B3;</td>
<td>&#x5403;&#x9C7C;</td>
</tr>
<tr>
<td>&#x6709;&#x76AE;&#x6BDB;</td>
<td>&#x6293;&#x8001;&#x9F20;</td>
</tr>
<tr>
<td></td>
<td>&#x7761;&#x89C9;</td>
</tr>
</tbody>
</table>
<p>&#x884C;&#x4E3A;&#x5F80;&#x5F80;&#x662F;&#x4EE5;&#x52A8;&#x8BCD;&#x5F00;&#x5934;&#xFF0C;&#x5728;&#x7F16;&#x7A0B;&#x4E2D;&#x7528;&#x4F7F;&#x7528;&#x51FD;&#x6570;&#x6765;&#x8868;&#x793A;&#xFF0C;&#x800C;&#x5C5E;&#x6027;&#x5219;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x6765;&#x8868;&#x793A;&#x3002;&#x7EAF;&#x7CB9;&#x7684;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7F16;&#x7A0B;&#x8BED;&#x8A00;&#x662F;Java&#x548C;C#&#xFF0C;&#x5176;&#x6B21;&#x652F;&#x6301;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7684;&#x8FD8;&#x6709;C++&#x548C;Python&#x7B49;&#x3002;</p>
<h3 id="&#x7C7B;&#x7684;&#x5B9A;&#x4E49;"><a name="&#x7C7B;&#x7684;&#x5B9A;&#x4E49;" class="anchor-navigation-ex-anchor" href="#&#x7C7B;&#x7684;&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7C7B;&#x7684;&#x5B9A;&#x4E49;</h3>
<pre><code class="lang-dart"><span class="hljs-comment">// Dart&#x4E2D;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7C7B;</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Person</span> </span>{
  <span class="hljs-built_in">String</span> name;
  <span class="hljs-built_in">int</span> age;

  Person(<span class="hljs-built_in">String</span> name, <span class="hljs-built_in">int</span> age) {
    <span class="hljs-keyword">this</span>.name = name;
    <span class="hljs-keyword">this</span>.age = age;
  }
}
</code></pre>
<p>Dart&#x4E2D;&#x7684;&#x7C7B;&#x4E0E;Java&#x4E2D;&#x7684;&#x76F8;&#x4F3C;&#xFF0C;&#x4E0D;&#x540C;&#x7684;&#x662F;&#xFF0C;Dart&#x4E2D;&#x6CA1;&#x6709;<code>private</code>&#x3001;<code>public</code>&#x8FD9;&#x4E9B;&#x6210;&#x5458;&#x8BBF;&#x95EE;&#x4FEE;&#x9970;&#x7B26;&#x3002;&#x5982;&#x679C;&#x662F;&#x7C7B;&#x79C1;&#x6709;&#x7684;&#x6210;&#x5458;&#xFF0C;&#x4E0D;&#x5E0C;&#x671B;&#x5916;&#x9762;&#x8BBF;&#x95EE;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x5728;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x4E4B;&#x524D;&#x52A0;&#x4E0A;&#x4E00;&#x4E2A;&#x4E0B;&#x5212;&#x7EBF;<code>_</code>&#x53D8;&#x4E3A;&#x79C1;&#x6709;&#x5373;&#x53EF;&#x3002;</p>
<p>&#x4EE5;&#x4E0A;&#x4EE3;&#x7801;&#xFF0C;&#x5728;Dart&#x4E2D;&#x8FD8;&#x6709;&#x4E00;&#x79CD;&#x7B80;&#x5316;&#x5199;&#x6CD5;&#xFF0C;&#x53EF;&#x4EE5;&#x81EA;&#x52A8;&#x5728;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4E2D;&#x5BF9;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x521D;&#x59CB;&#x5316;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// Dart&#x4E2D;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x7C7B;</span>
<span class="hljs-class"><span class="hljs-keyword">class</span>  <span class="hljs-title">Person</span> </span>{
    <span class="hljs-built_in">String</span> name;
    <span class="hljs-built_in">int</span> age;

    <span class="hljs-comment">// &#x5728;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4E2D;&#x521D;&#x59CB;&#x5316;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x65F6;&#xFF0C;&#x53EF;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x5199;&#x6CD5;&#x7B80;&#x5316;</span>
    Person(<span class="hljs-keyword">this</span>.name, <span class="hljs-keyword">this</span>.age);

    <span class="hljs-comment">// &#x5982;&#x9700;&#x5904;&#x7406;&#x5176;&#x4ED6;&#x53D8;&#x91CF;&#x65F6;&#xFF0C;&#x4E5F;&#x53EF;&#x5355;&#x72EC;&#x5BF9;&#x5176;&#x64CD;&#x4F5C;</span>
    <span class="hljs-comment">// Person(this.name, this.age, String address){</span>
    <span class="hljs-comment">//     print(address);</span>
    <span class="hljs-comment">// }</span>
    <span class="hljs-comment">// &#x6CE8;&#x610F;&#xFF0C;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4E0D;&#x80FD;&#x91CD;&#x8F7D;&#xFF0C;&#x4EE5;&#x4E0A;&#x6CE8;&#x91CA;&#x6389;</span>
}
</code></pre>
<p>&#x53E6;&#x5916;&#x8FD8;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x4E00;&#x70B9;&#xFF0C;Dart&#x4E2D;&#x6CA1;&#x6709;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x7684;&#x91CD;&#x8F7D;&#xFF0C;&#x4E0D;&#x80FD;&#x5199;&#x4E24;&#x4E2A;&#x540C;&#x540D;&#x7684;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x3002;</p>
<h3 id="getters-&#x548C;-setters&#x65B9;&#x6CD5;"><a name="getters-&#x548C;-setters&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#getters-&#x548C;-setters&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>Getters &#x548C; Setters&#x65B9;&#x6CD5;</h3>
<p>&#x5728;Java&#x4E2D;&#xFF0C;&#x4E00;&#x822C;&#x4E0D;&#x4F1A;&#x76F4;&#x63A5;&#x5728;&#x7C7B;&#x7684;&#x5916;&#x90E8;&#x53BB;&#x8BBF;&#x95EE;&#x7C7B;&#x6210;&#x5458;&#xFF0C;&#x901A;&#x5E38;&#x4F7F;&#x7528;setter&#x548C;getter&#x65B9;&#x6CD5;&#x6765;&#x64CD;&#x4F5C;&#x7C7B;&#x7684;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x3002;&#x800C;&#x5728;Dart&#x8BED;&#x8A00;&#x4E2D;&#xFF0C;&#x6240;&#x6709;&#x7C7B;&#x4E2D;&#x90FD;&#x5305;&#x542B;&#x9690;&#x5F0F;&#x7684;getter&#x65B9;&#x6CD5;&#xFF0C;&#x5BF9;&#x4E8E;&#x975E;<code>final</code>&#x4FEE;&#x9970;&#x7684;&#x6210;&#x5458;&#xFF0C;&#x7C7B;&#x4E2D;&#x8FD8;&#x5305;&#x542B;&#x9690;&#x5F0F;&#x7684;setter&#x65B9;&#x6CD5;&#x3002;&#x8FD9;&#x5C31;&#x610F;&#x5473;&#x7740;&#xFF0C;&#x5728;Dart&#x4E2D;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;&#x7C7B;&#x5916;&#x90E8;&#x901A;&#x8FC7;<code>.</code>&#x64CD;&#x4F5C;&#x7B26;&#x8BBF;&#x95EE;&#x7C7B;&#x6210;&#x5458;&#x3002;&#x8FD9;&#x4E00;&#x7279;&#x70B9;&#x4F7F;&#x5F97;Dart&#x8BED;&#x6CD5;&#x66F4;&#x52A0;&#x7B80;&#x6D01;&#xFF0C;&#x4E0D;&#x4F1A;&#x5199;&#x51FA;&#x6EE1;&#x5C4F;&#x7684;setXXX&#x3001;getXXX&#x65B9;&#x6CD5;&#x3002;</p>
<p>&#x5F53;&#x7136;&#xFF0C;&#x5F88;&#x591A;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x8C03;&#x7528;setter&#x548C;getter&#x65B9;&#x6CD5;&#x5E76;&#x4E0D;&#x4EC5;&#x4EC5;&#x662F;&#x4E3A;&#x4E86;&#x8D4B;&#x503C;&#x548C;&#x8BBF;&#x95EE;&#xFF0C;&#x800C;&#x662F;&#x4E3A;&#x4E86;&#x4E00;&#x4E9B;&#x989D;&#x5916;&#x7684;&#x5904;&#x7406;&#xFF0C;&#x8FD9;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x4F7F;&#x7528;<code>set</code>&#x4E0E;<code>get</code>&#x5173;&#x952E;&#x5B57;&#x5B9E;&#x73B0;setter&#x548C;getter&#x65B9;&#x6CD5;&#x5373;&#x53EF;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span>  <span class="hljs-title">Person</span> </span>{
    <span class="hljs-built_in">String</span> userName;

    Person(<span class="hljs-keyword">this</span>.userName);

    <span class="hljs-comment">// &#x65B9;&#x6CD5;&#x540D;&#x524D;&#x52A0;get&#x5173;&#x952E;&#x5B57;</span>
    <span class="hljs-built_in">String</span> <span class="hljs-keyword">get</span> name{
        <span class="hljs-keyword">return</span>  <span class="hljs-string">&quot;user:&quot;</span>  +  <span class="hljs-keyword">this</span>.userName;
    }

    <span class="hljs-comment">// &#x65B9;&#x6CD5;&#x540D;&#x524D;&#x52A0;set&#x5173;&#x952E;&#x5B57;</span>
    <span class="hljs-keyword">set</span> name(<span class="hljs-built_in">String</span> name){
        <span class="hljs-comment">// do something</span>
        <span class="hljs-keyword">this</span>.userName = name;
    }
}

<span class="hljs-keyword">void</span>  main() {
    <span class="hljs-keyword">var</span> p = <span class="hljs-keyword">new</span> Person(<span class="hljs-string">&quot;zhangsan&quot;</span>);
    <span class="hljs-built_in">print</span>(p.name);   <span class="hljs-comment">// user:zhangsan</span>
    p.name = <span class="hljs-string">&quot;Jack&quot;</span>;
    <span class="hljs-built_in">print</span>(p.name);   <span class="hljs-comment">// user:Jack</span>
}
</code></pre>
<p>&#x8981;&#x6CE8;&#x610F;&#xFF0C;&#x5728;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;&#x65F6;&#xFF0C;<code>new</code>&#x5173;&#x952E;&#x5B57;&#x5E76;&#x4E0D;&#x662F;&#x5FC5;&#x987B;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x7701;&#x7565;&#x4E0D;&#x5199;&#x3002;&#x5728;&#x5199;Flutter&#x754C;&#x9762;&#x65F6;&#xFF0C;&#x4E0D;&#x5EFA;&#x8BAE;&#x5199;<code>new</code>&#x5173;&#x952E;&#x5B57;&#x5B9E;&#x4F8B;&#x5316;&#x5BF9;&#x8C61;&#xFF0C;&#x56E0;&#x4E3A;Flutter&#x6846;&#x67B6;&#x4E2D;&#x6CA1;&#x6709;&#x7C7B;&#x4F3C;&#x7684;xml&#x8BED;&#x8A00;&#x6765;&#x63CF;&#x8FF0;UI&#x754C;&#x9762;&#xFF0C;&#x754C;&#x9762;&#x4E5F;&#x662F;&#x4F7F;&#x7528;Dart&#x8BED;&#x8A00;&#x6765;&#x5199;&#xFF0C;&#x5728;&#x4F7F;&#x7528;Dart&#x5199;UI&#x65F6;&#xFF0C;&#x8981;&#x4FDD;&#x6301;&#x4EE3;&#x7801;&#x7684;&#x7B80;&#x6D01;&#x548C;&#x7ED3;&#x6784;&#x5316;&#xFF0C;&#x7701;&#x7565;<code>new</code>&#x4F1A;&#x66F4;&#x53CB;&#x597D;&#x3002;</p>
<h3 id="&#x6784;&#x9020;&#x65B9;&#x6CD5;"><a name="&#x6784;&#x9020;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x6784;&#x9020;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6784;&#x9020;&#x65B9;&#x6CD5;</h3>
<blockquote>
<p>&#x5982;&#x679C;&#x6CA1;&#x6709;&#x5B9A;&#x4E49;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF0C;&#x5219;&#x4F1A;&#x6709;&#x4E00;&#x4E2A;&#x9ED8;&#x8BA4;&#x7684;&#x65E0;&#x53C2;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF0C;&#x5E76;&#x4E14;&#x4F1A;&#x8C03;&#x7528;&#x8D85;&#x7C7B;&#x7684;&#x65E0;&#x53C2;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x3002;</p>
</blockquote>
<h4 id="&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;"><a name="&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;</h4>
<p>&#x4E0A;&#x9762;&#x5DF2;&#x7ECF;&#x8BF4;&#x8FC7;&#xFF0C;Dart&#x7C7B;&#x4E2D;&#x4E24;&#x4E2A;&#x540C;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4E0D;&#x80FD;&#x91CD;&#x8F7D;&#xFF0C;&#x4F46;&#x662F;Dart&#x8BED;&#x8A00;&#x4E3A;&#x7C7B;&#x65B0;&#x589E;&#x4E86;&#x4E00;&#x79CD;&#x79F0;&#x4E3A;<code>&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;</code>&#x7684;&#x4E1C;&#x897F;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span>  <span class="hljs-title">Person</span> </span>{
    <span class="hljs-built_in">String</span> userName;
    <span class="hljs-built_in">int</span> age;

    Person(<span class="hljs-keyword">this</span>.userName, <span class="hljs-keyword">this</span>.age);

    <span class="hljs-comment">// &#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
    Person.fromData(<span class="hljs-built_in">Map</span> data) {
        <span class="hljs-keyword">this</span>.userName = data[<span class="hljs-string">&apos;name&apos;</span>];
        <span class="hljs-keyword">this</span>.age = data[<span class="hljs-string">&apos;age&apos;</span>];
    }
}

<span class="hljs-keyword">void</span>  main() {
    <span class="hljs-comment">// &#x4F7F;&#x7528;&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;</span>
    <span class="hljs-keyword">var</span> p = <span class="hljs-keyword">new</span> Person.fromData({
        <span class="hljs-string">&quot;name&quot;</span>:<span class="hljs-string">&quot;Bob&quot;</span>,
        <span class="hljs-string">&quot;age&quot;</span>:<span class="hljs-number">19</span>
    });
    <span class="hljs-built_in">print</span>(p.userName);
}
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x4F7F;&#x7528;&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x4E3A;&#x4E00;&#x4E2A;&#x7C7B;&#x5B9E;&#x73B0;&#x591A;&#x4E2A;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x66F4;&#x6E05;&#x6670;&#x7684;&#x8868;&#x660E;&#x610F;&#x56FE;&#x3002;</p>
<h4 id="&#x5E38;&#x91CF;&#x6784;&#x9020;&#x65B9;&#x6CD5;"><a name="&#x5E38;&#x91CF;&#x6784;&#x9020;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x91CF;&#x6784;&#x9020;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5E38;&#x91CF;&#x6784;&#x9020;&#x65B9;&#x6CD5;</h4>
<blockquote>
<p>&#x5982;&#x679C;&#x60F3;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x72B6;&#x6001;&#x6C38;&#x8FDC;&#x4E0D;&#x53D8;&#x7684;&#x5BF9;&#x50CF;&#xFF0C;&#x5728;Dart&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x7F16;&#x8BD1;&#x65F6;&#x5E38;&#x91CF;&#x5BF9;&#x8C61;&#xFF0C;&#x8282;&#x7701;&#x5F00;&#x9500;&#x3002;</p>
</blockquote>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span>  <span class="hljs-title">ConstPoint</span> </span>{
    <span class="hljs-keyword">final</span> <span class="hljs-built_in">num</span> x;
    <span class="hljs-keyword">final</span> <span class="hljs-built_in">num</span> y;

    <span class="hljs-comment">// &#x4F7F;&#x7528;const&#x4FEE;&#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
    <span class="hljs-keyword">const</span> ConstPoint(<span class="hljs-keyword">this</span>.x, <span class="hljs-keyword">this</span>.y);

    <span class="hljs-comment">// &#x7F16;&#x8BD1;&#x65F6;&#x5E38;&#x91CF;&#x5BF9;&#x8C61;&#xFF0C;&#x9700;&#x4F7F;&#x7528;const&#x6765;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;</span>
    <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> ConstPoint origin = <span class="hljs-keyword">const</span>  ConstPoint(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>);
}

<span class="hljs-keyword">void</span>  main() {
    <span class="hljs-built_in">print</span>(ConstPoint.origin.x);
    <span class="hljs-built_in">print</span>(ConstPoint.origin.y);
}
</code></pre>
<h4 id="&#x5DE5;&#x5382;&#x6784;&#x9020;&#x65B9;&#x6CD5;"><a name="&#x5DE5;&#x5382;&#x6784;&#x9020;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x5DE5;&#x5382;&#x6784;&#x9020;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5DE5;&#x5382;&#x6784;&#x9020;&#x65B9;&#x6CD5;</h4>
<p>&#x5F53;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x5BF9;&#x8C61;&#x6216;&#x8005;&#x4ECE;&#x7F13;&#x5B58;&#x4E2D;&#x53D6;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x65F6;&#xFF0C;&#x5DE5;&#x5382;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x5C31;&#x6D3E;&#x4E0A;&#x4E86;&#x7528;&#x573A;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span>  <span class="hljs-title">Logger</span> </span>{
    <span class="hljs-keyword">final</span> <span class="hljs-built_in">String</span> name;

    <span class="hljs-comment">// &#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x9759;&#x6001;Map&#x505A;&#x4E3A;&#x7F13;&#x5B58;</span>
    <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-built_in">Map</span>&lt;<span class="hljs-built_in">String</span>, Logger&gt; _cache =  &lt;<span class="hljs-built_in">String</span>, Logger&gt;{};

    <span class="hljs-comment">// &#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF0C;&#x7528;&#x4E0B;&#x5212;&#x7EBF;&quot;_&quot;&#x4FEE;&#x9970;&#xFF0C;&#x5C06;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x79C1;&#x6709;&#x5316;</span>
    Logger._internal(<span class="hljs-keyword">this</span>.name);

    <span class="hljs-comment">// &#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57;factory&#x4FEE;&#x9970;&#x7C7B;&#x540C;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
    <span class="hljs-keyword">factory</span> Logger(<span class="hljs-built_in">String</span> name) {
        <span class="hljs-keyword">if</span> (_cache.containsKey(name)) {
            <span class="hljs-keyword">return</span> _cache[name];
        } <span class="hljs-keyword">else</span> {
            <span class="hljs-comment">// &#x8C03;&#x7528;&#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x521B;&#x5EFA;&#x65B0;&#x5BF9;&#x8C61;</span>
            <span class="hljs-keyword">final</span> logger= <span class="hljs-keyword">new</span>  Logger._internal(name);
            _cache[name] = logger; <span class="hljs-comment">// &#x5B58;&#x5165;&#x7F13;&#x5B58;</span>
            <span class="hljs-keyword">return</span> logger;
        }
    }
}

<span class="hljs-keyword">void</span>  main() {
    <span class="hljs-keyword">var</span> uiLog = <span class="hljs-keyword">new</span> Logger(<span class="hljs-string">&apos;UI&apos;</span>);
    <span class="hljs-keyword">var</span> eventLog = <span class="hljs-keyword">new</span> Logger(<span class="hljs-string">&apos;event&apos;</span>);
}
</code></pre>
<h4 id="&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x91CD;&#x5B9A;&#x5411;"><a name="&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x91CD;&#x5B9A;&#x5411;" class="anchor-navigation-ex-anchor" href="#&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x91CD;&#x5B9A;&#x5411;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x91CD;&#x5B9A;&#x5411;</h4>
<p>&#x6709;&#x65F6;&#x5019;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4F1A;&#x8C03;&#x52A8;&#x7C7B;&#x4E2D;&#x7684;&#x5176;&#x4ED6;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x6765;&#x5B9E;&#x4F8B;&#x5316;&#xFF0C;&#x8FD9;&#x65F6;&#x5019;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x91CD;&#x5B9A;&#x5411;&#xFF0C;</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Point</span> </span>{
  <span class="hljs-built_in">num</span> x;
  <span class="hljs-built_in">num</span> y;

  <span class="hljs-comment">// &#x540C;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;</span>
  Point(<span class="hljs-keyword">this</span>.x, <span class="hljs-keyword">this</span>.y);

  <span class="hljs-comment">// &#x547D;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x91CD;&#x5B9A;&#x5411;&#x5230;&#x540C;&#x540D;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF0C;&#x4E2D;&#x95F4;&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x5192;&#x53F7;</span>
  Point.alongXAxis(<span class="hljs-built_in">num</span> x) : <span class="hljs-keyword">this</span>(x, <span class="hljs-number">0</span>);
}
</code></pre>
<h3 id="&#x7C7B;&#x7684;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;"><a name="&#x7C7B;&#x7684;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;" class="anchor-navigation-ex-anchor" href="#&#x7C7B;&#x7684;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7C7B;&#x7684;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;</h3>
<p>&#x719F;&#x6089;C++&#x7684;&#x670B;&#x53CB;&#x5E94;&#x8BE5;&#x5BF9;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;&#x5F88;&#x4E86;&#x89E3;&#x4E86;&#xFF0C;Java&#x4E2D;&#x662F;&#x6CA1;&#x6709;&#x8FD9;&#x4E2A;&#x7279;&#x6027;&#x7684;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span>  <span class="hljs-title">Point</span> </span>{
    <span class="hljs-keyword">final</span>  <span class="hljs-built_in">num</span> x;
    <span class="hljs-keyword">final</span>  <span class="hljs-built_in">num</span> y;
    <span class="hljs-keyword">final</span>  <span class="hljs-built_in">num</span> distance;

    Point(x, y)
        : x = x,
          y = y,
          distance =  sqrt(x * x + y * y){
             <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;&#x8FD9;&#x662F;&#x6784;&#x9020;&#x65B9;&#x6CD5;&quot;</span>);
          }
}

<span class="hljs-keyword">void</span>  main() {
    <span class="hljs-keyword">var</span> p =  <span class="hljs-keyword">new</span>  Point(<span class="hljs-number">2</span>, <span class="hljs-number">3</span>);
    <span class="hljs-built_in">print</span>(p.distance);
}
</code></pre>
<p><img src="https://img-blog.csdnimg.cn/20190323003650911.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9hcmN0aWNmb3guYmxvZy5jc2RuLm5ldA==,size_16,color_FFFFFF,t_70" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<ul>
<li>&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;&#x4F4D;&#x4E8E;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x7684;&#x5C0F;&#x62EC;&#x53F7;&#x4E0E;&#x5927;&#x62EC;&#x53F7;&#x4E4B;&#x95F4;&#xFF0C;&#x5728;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;&#x4E4B;&#x524D;&#x9700;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x5192;&#x53F7;&#x3002;</li>
<li>&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;&#x662F;&#x7531;&#x9017;&#x53F7;&#x5206;&#x9694;&#x7684;&#x4E00;&#x4E9B;&#x8D4B;&#x503C;&#x8BED;&#x53E5;&#x7EC4;&#x6210;&#x3002;</li>
<li>&#x5B83;&#x9002;&#x5408;&#x7528;&#x6765;&#x521D;&#x59CB;&#x5316; <code>final</code>&#x4FEE;&#x9970;&#x7684;&#x53D8;&#x91CF;</li>
<li>&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;&#x7684;&#x8C03;&#x7528;&#x662F;&#x5728;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x4E4B;&#x524D;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x5728;&#x7C7B;&#x5B8C;&#x6210;&#x5B9E;&#x4F8B;&#x5316;&#x4E4B;&#x524D;&#xFF0C;&#x56E0;&#x6B64;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;&#x4E2D;&#x662F;&#x4E0D;&#x80FD;&#x8BBF;&#x95EE; <code>this</code>&#x7684;</li>
</ul>
<h3 id="&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;"><a name="&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;" class="anchor-navigation-ex-anchor" href="#&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;</h3>
<p>&#x8FD9;&#x4E2A;&#x7279;&#x6027;&#xFF0C;&#x53C8;&#x5F88;&#x7C7B;&#x4F3C;&#x4E8E;C++&#x4E2D;&#x7684;&#x8FD0;&#x7B97;&#x7B26;&#x91CD;&#x8F7D;&#xFF0C;&#x5728;Java&#x4E2D;&#x662F;&#x6CA1;&#x7528;&#x8FD9;&#x79CD;&#x6982;&#x5FF5;&#x7684;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Point</span> </span>{
  <span class="hljs-built_in">int</span> x;
  <span class="hljs-built_in">int</span> y;

  Point(<span class="hljs-keyword">this</span>.x, <span class="hljs-keyword">this</span>.y);

  <span class="hljs-comment">// &#x4F7F;&#x7528;operator&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x4E3A;&#x8BE5;&#x7C7B;&#x91CD;&#x8F7D;&quot;+&quot;&#x8FD0;&#x7B97;&#x7B26;</span>
  Point <span class="hljs-keyword">operator</span> +(Point p) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Point(<span class="hljs-keyword">this</span>.x + p.x, <span class="hljs-keyword">this</span>.y + p.y);
  }

  <span class="hljs-comment">// &#x4E3A;&#x8BE5;&#x7C7B;&#x91CD;&#x8F7D;&quot;-&quot;&#x8FD0;&#x7B97;&#x7B26;</span>
  Point <span class="hljs-keyword">operator</span> -(Point p) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Point(<span class="hljs-keyword">this</span>.x - p.x, <span class="hljs-keyword">this</span>.y - p.y);
  }
}

<span class="hljs-keyword">void</span> main(){
   <span class="hljs-keyword">var</span> p1 = <span class="hljs-keyword">new</span> Point(<span class="hljs-number">1</span>,<span class="hljs-number">5</span>);
   <span class="hljs-keyword">var</span> p2 = <span class="hljs-keyword">new</span> Point(<span class="hljs-number">7</span>,<span class="hljs-number">10</span>);

   <span class="hljs-comment">// &#x91CD;&#x8F7D;&#x8FD0;&#x7B97;&#x7B26;&#x540E;&#xFF0C;&#x7C7B;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x201C;+&#x201D;&#x3001;&#x201C;-&#x201D; &#x8FD0;&#x7B97;&#x7B26;&#x64CD;&#x4F5C;</span>
   <span class="hljs-keyword">var</span> p3 = p1 + p2;
   <span class="hljs-keyword">var</span> p4 = p2 - p1;

   <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;<span class="hljs-subst">${p3.x}</span>, <span class="hljs-subst">${p3.y}</span>&quot;</span>);
   <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;<span class="hljs-subst">${p4.x}</span>, <span class="hljs-subst">${p4.y}</span>&quot;</span>);
}
</code></pre>
<p>&#x6253;&#x5370;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre><code>8, 15
6, 5
</code></pre><p>Dart&#x4E2D;&#x5141;&#x8BB8;&#x91CD;&#x8F7D;&#x7684;&#x8FD0;&#x7B97;&#x7B26;&#x5982;&#x4E0B;&#xFF1A;</p>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><code>+</code></td>
<td><code>&#x2013;</code></td>
<td><code>*</code></td>
<td><code>~/</code></td>
<td><code>/</code></td>
<td><code>%</code></td>
<td><code>^</code></td>
</tr>
<tr>
<td><code>&lt;</code></td>
<td><code>&gt;</code></td>
<td><code>&lt;=</code></td>
<td><code>&gt;=</code></td>
<td><code>==</code></td>
<td><code>[]</code></td>
<td><code>[]=</code></td>
</tr>
<tr>
<td><code>&amp;</code></td>
<td><code>~</code></td>
<td><code>&lt;&lt;</code></td>
<td><code>&gt;&gt;</code></td>
<td>|</td>
<td></td>
</tr>
</tbody>
</table>
<h3 id="&#x7C7B;&#x7684;&#x7EE7;&#x627F;&#x4E0E;&#x6DF7;&#x5165;"><a name="&#x7C7B;&#x7684;&#x7EE7;&#x627F;&#x4E0E;&#x6DF7;&#x5165;" class="anchor-navigation-ex-anchor" href="#&#x7C7B;&#x7684;&#x7EE7;&#x627F;&#x4E0E;&#x6DF7;&#x5165;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7C7B;&#x7684;&#x7EE7;&#x627F;&#x4E0E;&#x6DF7;&#x5165;</h3>
<p><img src="https://imgconvert.csdnimg.cn/aHR0cHM6Ly91c2VyLWdvbGQtY2RuLnhpdHUuaW8vMjAxOS84LzQvMTZjNWQwZGY1NzUyZjA2NA" alt=""></p>
<p>Dart&#x4E2D;&#x7684;&#x7EE7;&#x627F;&#xFF0C;&#x4E0E;Java&#x4E2D;&#x76F8;&#x4F3C;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57;<code>extends</code>&#x7EE7;&#x627F;&#x7236;&#x7C7B;&#xFF0C;&#x4F7F;&#x7528;&#x5173;&#x952E;&#x5B57;<code>super</code>&#x5F15;&#x7528;&#x7236;&#x7C7B;</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Father</span> </span>{
    myFunction(){
        <span class="hljs-comment">// do something</span>
    }
}

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Son</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Father</span> </span>{

    <span class="hljs-meta">@override</span>
    myFunction(){
        <span class="hljs-keyword">super</span>.myFunction();
        <span class="hljs-comment">// do something</span>
    }
}
</code></pre>
<p>&#x6211;&#x4EEC;&#x77E5;&#x9053;&#xFF0C;Java&#x4E2D;&#x7684;&#x7C7B;&#x4EC5;&#x652F;&#x6301;&#x5355;&#x7EE7;&#x627F;&#xFF0C;&#x800C;Dart&#x4E2D;&#x7684;&#x7C7B;&#x4E5F;&#x53EA;&#x652F;&#x6301;&#x5355;&#x7EE7;&#x627F;&#x3002;&#x4F46;&#x662F;Dart&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E00;&#x79CD;&#x88AB;&#x79F0;&#x4E3A;&#x6DF7;&#x5165;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x8FBE;&#x5230;&#x591A;&#x7EE7;&#x627F;&#x7684;&#x6548;&#x679C;&#xFF0C;&#x8FD9;&#x9700;&#x8981;&#x4F7F;&#x7528;<code>with</code>&#x5173;&#x952E;&#x5B57;&#x3002;</p>
<pre><code class="lang-dart"><span class="hljs-comment">// &#x9996;&#x5148;&#x5B9A;&#x4E49;&#x4E09;&#x4E2A;&#x7236;&#x7C7B;</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Father1</span> </span>{
    a(){
      <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;this is a func&quot;</span>);
    }

    common(){
        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;common Father1&quot;</span>);
    }
}

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Father2</span> </span>{
    b(){
      <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;this is b func&quot;</span>);
    }

    common(){
        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;common Father2&quot;</span>);
    }
}

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Father3</span> </span>{
    c(){
      <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;this is c func&quot;</span>);
    }

    common(){
        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;common Father3&quot;</span>);
    }
}

<span class="hljs-comment">//&#x5B9A;&#x4E49;&#x5B50;&#x7C7B;</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Son</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Father1</span> <span class="hljs-title">with</span> <span class="hljs-title">Father2</span>,<span class="hljs-title">Father3</span></span>{

}

<span class="hljs-keyword">void</span> main() {
  <span class="hljs-keyword">var</span> obj = <span class="hljs-keyword">new</span> Son();
  obj.common();
  obj.a();
  obj.b();
  obj.c();
}
</code></pre>
<p>&#x6253;&#x5370;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre><code>common Father3
this is a func
this is b func
this is c func
</code></pre><p>&#x8981;&#x6CE8;&#x610F;&#xFF0C;&#x4EE5;&#x4E0A;&#x5199;&#x6CD5;&#x4E2D;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;<code>with</code>&#xFF0C;&#x7B49;&#x4EF7;&#x4E8E;&#x5982;&#x4E0B;&#x5199;&#x6CD5;</p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Son</span> <span class="hljs-title">with</span> <span class="hljs-title">Father1</span>,<span class="hljs-title">Father2</span>,<span class="hljs-title">Father3</span></span>{

}
</code></pre>
<h4 id="&#x6DF7;&#x5165;&#xFF08;mixin&#xFF09;"><a name="&#x6DF7;&#x5165;&#xFF08;mixin&#xFF09;" class="anchor-navigation-ex-anchor" href="#&#x6DF7;&#x5165;&#xFF08;mixin&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6DF7;&#x5165;&#xFF08;mixin&#xFF09;</h4>
<p>&#x6709;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x4E00;&#x79CD;&#x5728;&#x591A;&#x4E2A;&#x7C7B;&#x5C42;&#x6B21;&#x7ED3;&#x6784;&#x4E2D;&#x91CD;&#x7528;&#x4EE3;&#x7801;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x6DF7;&#x5165;&#x6B63;&#x662F;&#x4E3A;&#x4E86;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#x800C;&#x51FA;&#x73B0;&#x7684;&#x3002;</p>
<ul>
<li><code>mixin</code>&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x7C7B;&#x4F3C;&#x591A;&#x91CD;&#x7EE7;&#x627F;&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x4F46;&#x662F;&#x591A;&#x91CD;&#x7EE7;&#x627F;&#x4E2D;&#x76F8;&#x540C;&#x51FD;&#x6570;&#x5E76;&#x4E0D;&#x4F1A;&#x5B58;&#x5728;&#x7236;&#x5B50;&#x5173;&#x7CFB;</li>
<li><code>mixin</code> &#x5B9E;&#x73B0;&#x4E86;&#x4E00;&#x6761;&#x7EBF;&#x6027;&#x7EE7;&#x627F;&#x94FE;&#xFF0C;&#x58F0;&#x660E;&#x7684;&#x987A;&#x5E8F;&#x4EE3;&#x8868;&#x4E86;&#x7EE7;&#x627F;&#x7684;&#x987A;&#x5E8F;&#xFF0C;&#x5982;&#x679C;&#x5B58;&#x5728;&#x540C;&#x540D;&#x65B9;&#x6CD5;&#xFF0C;&#x90A3;&#x4E48;&#x58F0;&#x660E;&#x5728;&#x6700;&#x540E;&#x7684;&#x6DF7;&#x5165;&#x4E2D;&#x7684;&#x65B9;&#x6CD5;&#x4F1A;&#x8986;&#x76D6;&#x524D;&#x9762;&#x7684;</li>
<li><code>mixin</code>&#x662F;&#x5176;&#x8D85;&#x7C7B;&#x7684;&#x5B50;&#x7C7B;&#x578B;&#xFF0C;&#x4E5F;&#x662F;mixin&#x540D;&#x79F0;&#x672C;&#x8EAB;&#x8868;&#x793A;&#x7684;&#x7C7B;&#x7684;&#x5B50;&#x7C7B;&#x578B;</li>
<li>&#x6700;&#x65B0;&#x7684;SDK&#x7248;&#x672C;&#xFF0C;&#x5728;<code>mixin</code>&#x4E2D;&#x53EF;&#x4EE5;&#x8C03;&#x7528;super</li>
</ul>
<p><code>mixin</code>&#x7684;&#x53E6;&#x4E00;&#x79CD;&#x4F7F;&#x7528;&#x65B9;&#x5F0F;</p>
<pre><code class="lang-dart">
mixin Walker{
    <span class="hljs-keyword">void</span> walk(){
        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;walk&quot;</span>);
    }
}

mixin Swim{
    <span class="hljs-keyword">void</span> swim(){
        <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;swim&quot;</span>);
    }
}

<span class="hljs-comment">// &#x58F0;&#x660E;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;</span>
mixin Flying {
  <span class="hljs-keyword">void</span> flying();
}
</code></pre>
<p><code>mixin</code>&#x4E0E;<code>on</code>&#x5173;&#x952E;&#x5B57;&#x7684;&#x914D;&#x5408;</p>
<pre><code>// &#x9650;&#x5B9A;&#x4F7F;&#x7528;&#x8303;&#x56F4;&#xFF0C;&#x8981;&#x6DF7;&#x5165;Swim&#x5FC5;&#x987B;&#x662F;Human&#x7684;&#x5B50;&#x7C7B;
mixin Swim on Human {

}
</code></pre><h3 id="&#x63A5;&#x53E3;&#x62BD;&#x8C61;"><a name="&#x63A5;&#x53E3;&#x62BD;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x63A5;&#x53E3;&#x62BD;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x63A5;&#x53E3;&#x62BD;&#x8C61;</h3>
<h4 id="&#x62BD;&#x8C61;&#x7C7B;"><a name="&#x62BD;&#x8C61;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#&#x62BD;&#x8C61;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x62BD;&#x8C61;&#x7C7B;</h4>
<blockquote>
<p>Dart&#x8BED;&#x8A00;&#x6CA1;&#x6709;&#x63D0;&#x4F9B;<code>interface</code>&#x5173;&#x952E;&#x5B57;&#x6765;&#x5B9A;&#x4E49;&#x63A5;&#x53E3;&#xFF0C;&#x4F46;&#x662F;Dart&#x8BED;&#x8A00;&#x4E2D;&#x4FDD;&#x7559;&#x4E86;&#x62BD;&#x8C61;&#x7C7B;&#xFF0C;&#x540C;Java&#xFF0C;&#x4F7F;&#x7528;<code>abstract</code>&#x5173;&#x952E;&#x5B57;&#x6765;&#x4FEE;&#x9970;&#x62BD;&#x8C61;&#x7C7B;&#x3002;&#x800C;Dart&#x4E2D;&#x7684;&#x62BD;&#x8C61;&#x7C7B;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x5C31;&#x76F8;&#x5F53;&#x4E8E;Java&#x4E2D;&#x7684;&#x63A5;&#x53E3;&#x3002;</p>
</blockquote>
<pre><code class="lang-dart"><span class="hljs-keyword">abstract</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Base</span> </span>{
    <span class="hljs-comment">// &#x7701;&#x7565;&#x51FD;&#x6570;&#x4F53;&#x5373;&#x53EF;&#x5B9A;&#x4E49;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#xFF0C;&#x4E0D;&#x9700;&#x52A0;&#x5173;&#x952E;&#x5B57;</span>
    func1();
    func2();
}
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x62BD;&#x8C61;&#x7C7B;&#x662F;&#x4E0D;&#x80FD;&#x88AB;&#x5B9E;&#x4F8B;&#x5316;&#x7684;&#xFF0C;&#x5B50;&#x7C7B;&#x7EE7;&#x627F;&#x62BD;&#x8C61;&#x7C7B;&#x65F6;&#xFF0C;&#x5FC5;&#x987B;&#x5B9E;&#x73B0;&#x5168;&#x90E8;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x3002;</p>
<h4 id="&#x9690;&#x5F0F;&#x63A5;&#x53E3;"><a name="&#x9690;&#x5F0F;&#x63A5;&#x53E3;" class="anchor-navigation-ex-anchor" href="#&#x9690;&#x5F0F;&#x63A5;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9690;&#x5F0F;&#x63A5;&#x53E3;</h4>
<blockquote>
<p>&#x5B9E;&#x9645;&#x4E0A;&#x5728;Dart&#x4E2D;&#xFF0C;&#x6BCF;&#x4E2A;&#x7C7B;&#x90FD;&#x9690;&#x5F0F;&#x7684;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;&#x5305;&#x542B;&#x6240;&#x6709;&#x5B9E;&#x4F8B;&#x6210;&#x5458;&#x7684;&#x63A5;&#x53E3;&#xFF0C; &#x5E76;&#x4E14;&#x8BE5;&#x7C7B;&#x5B9E;&#x73B0;&#x4E86;&#x8FD9;&#x4E2A;&#x63A5;&#x53E3;&#x3002;</p>
</blockquote>
<p>&#x56E0;&#x6B64;&#xFF0C;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x5B9E;&#x73B0;&#x67D0;&#x4E2A;&#x63A5;&#x53E3;&#xFF0C;&#x4F46;&#x6709;&#x53C8;&#x4E0D;&#x60F3;&#x7EE7;&#x627F;&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FD9;&#x79CD;&#x9690;&#x5F0F;&#x63A5;&#x53E3;&#x673A;&#x5236;&#x3002;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x7528;&#x5230;&#x5173;&#x952E;&#x5B57;<code>implements</code></p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">People</span> </span>{
  <span class="hljs-keyword">void</span> greet(){
    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Hello&quot;</span>);
  }
}

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Student</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">People</span></span>{
  <span class="hljs-meta">@override</span>
  <span class="hljs-keyword">void</span> greet(){
    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Hi,I&apos;m Alice.&quot;</span>);
  }
}

greet(People p){
  p.greet();
}

<span class="hljs-keyword">void</span> main() {
  greet(<span class="hljs-keyword">new</span> Student());
}
</code></pre>
<hr>
<p><strong>&#x516C;&#x4F17;&#x53F7;&#x201C;&#x7F16;&#x7A0B;&#x4E4B;&#x8DEF;&#x4ECE;0&#x5230;1&#x201D;</strong></p>
<p><img src="https://gitee.com/arcticfox1919/ImageHosting/raw/master/img/20190301102949549.jpg" alt="20190301102949549"> </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; Arcticfox 2020 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x6863;&#x4FEE;&#x8BA2;&#x4E8E;&#xFF1A;
2021-03-18 13:33:53
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="进阶篇.html" class="navigation navigation-prev " aria-label="Previous page: 进阶篇">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="泛型.html" class="navigation navigation-next " aria-label="Next page: 泛型">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"面向对象","level":"1.3.1","depth":2,"next":{"title":"泛型","level":"1.3.2","depth":2,"path":"泛型.md","ref":"泛型.md","articles":[]},"previous":{"title":"进阶篇","level":"1.3","depth":1,"path":"进阶篇.md","ref":"进阶篇.md","articles":[{"title":"面向对象","level":"1.3.1","depth":2,"path":"面向对象.md","ref":"面向对象.md","articles":[]},{"title":"泛型","level":"1.3.2","depth":2,"path":"泛型.md","ref":"泛型.md","articles":[]},{"title":"枚举","level":"1.3.3","depth":2,"path":"枚举.md","ref":"枚举.md","articles":[]},{"title":"库与导入","level":"1.3.4","depth":2,"path":"库与导入.md","ref":"库与导入.md","articles":[]},{"title":"异步编程","level":"1.3.5","depth":2,"path":"异步编程.md","ref":"异步编程.md","articles":[{"title":"Future","level":"1.3.5.1","depth":3,"path":"异步编程之Future.md","ref":"异步编程之Future.md","articles":[]},{"title":"Stream","level":"1.3.5.2","depth":3,"path":"异步编程之Stream.md","ref":"异步编程之Stream.md","articles":[]},{"title":"Isolate","level":"1.3.5.3","depth":3,"path":"异步编程之Isolate.md","ref":"异步编程之Isolate.md","articles":[]}]},{"title":"异常处理与 Zone","level":"1.3.6","depth":2,"path":"异常处理.md","ref":"异常处理.md","articles":[]},{"title":"生成器","level":"1.3.7","depth":2,"path":"生成器.md","ref":"生成器.md","articles":[]},{"title":"标准流与文件","level":"1.3.8","depth":2,"path":"标准流与文件.md","ref":"标准流与文件.md","articles":[]},{"title":"附：运算符","level":"1.3.9","depth":2,"path":"运算符.md","ref":"运算符.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["anchor-navigation-ex","expandable-chapters-small","-lunr","-search","search-pro","-sharing","github","expandable-chapters","pageview-count","theme-comscore","tbfed-pagefooter","popup","custom-favicon"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy Arcticfox 2020","modify_label":"文档修订于：","modify_format":"YYYY-MM-DD HH:mm:ss"},"github":{"url":"https://github.com/arcticfox1919"},"search-pro":{},"popup":{},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":"logo.ico","theme-comscore":{},"pageview-count":{},"custom-favicon":{},"expandable-chapters-small":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"arcticfox","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Dart编程指南","language":"zh-hans","links":{"sidebar":{"主页":"http://www.bczl.xyz/"}},"gitbook":"*"},"file":{"path":"面向对象.md","mtime":"2021-03-18T05:33:53.799Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-10-18T14:58:03.414Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

